#include "Channel.h"

Channel::Channel(int fd, int event, handleFunc readCallBack, handleFunc writeCallBack, handleFunc destoryCallBack, void *arg)
{
    this->m_arg = arg;
    this->m_fd = fd;
    this->m_event = event;
    this->readCallBack = readCallBack;
    this->writeCallBack = writeCallBack;
    this->destoryCallBack = destoryCallBack;
}

void Channel::updateWriteEvent(bool flag)
{
    if (flag)
    {
        this->m_event = this->m_event | static_cast<int>(FDEvent::ReadEvent);
    }
    else
    {
        this->m_event = this->m_event & ~ static_cast<int>(FDEvent::WriteEvent);
    }
}

bool Channel::isWriteEventEnable()
{
    return this->m_event & static_cast<int>(FDEvent::WriteEvent);
}




